#!/sbin/openrc-run

supervisor=supervise-daemon

command="/usr/bin/headscale"
command_args="serve"
command_user="headscale:headscale"
directory="/var/lib/headscale"

output_log="/var/log/headscale.log"
error_log="/var/log/headscale.log"

depend() {
	need net
	after firewall
}

start_pre() {
	checkpath -d -m 755 -o "headscale:headscale" /var/run/headscale
	checkpath -d -m 755 -o "headscale:headscale" /var/lib/headscale

	checkpath -f -m 644 -o "headscale:headscale" /var/lib/headscale/db.sqlite
	checkpath -f -m 644 -o "headscale:headscale" /etc/headscale/config.yaml
	checkpath -f -m 644 -o "headscale:headscale" /var/log/headscale.log
}
